package 包装类;

public class 综合练习三 {
    public static void main(String[] args) {
        //定义
        //个方法自己实现toBinaryString方法的效果，将
        //十进制整数转成字符串表示的二进制

        System.out.println(toBinaryString(6));
        System.out.println(Integer.toBinaryString(6));
    }public static String toBinaryString(int number){
        StringBuilder sb=new StringBuilder();

        while (true){
            if(number==0){
                break;
            }
            int remainder=number%2;
            sb.insert(0,remainder);
            System.out.println(remainder);
            number=number/2;

        }
        return sb.toString();
    }
}
